//
//  SettingViewController.m
//  Powertech
//
//  Created by 魏延(颜魏) on 2024/12/9.
//

#import "SettingViewController.h"
#import "DeviceSettingViewController.h"
#import "BTManager.h"
#import "DCControlViewController.h"

@interface SettingViewController ()

@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UILabel *websiteLabel;
@property (weak, nonatomic) IBOutlet UIImageView *logoIV;
@property (weak, nonatomic) IBOutlet UIButton *contrBtn;

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.phoneLabel.userInteractionEnabled = YES;
    self.websiteLabel.userInteractionEnabled = YES;
    self.logoIV.userInteractionEnabled = YES;

    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap1:)];
    [self.phoneLabel addGestureRecognizer:tap1];
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap2:)];
    [self.websiteLabel addGestureRecognizer:tap2];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
    tap.numberOfTapsRequired = 10;
    [self.logoIV addGestureRecognizer:tap];
    
    self.contrBtn.layer.shadowColor = [UIColor lightGrayColor].CGColor;
    self.contrBtn.layer.shadowOffset = CGSizeMake(0, 3);
    self.contrBtn.layer.shadowOpacity = 0.7;
    self.contrBtn.layer.shadowRadius = 5;
}

- (void)setShowDC:(BOOL)showDC {
    _showDC = showDC;
    self.contrBtn.hidden = !showDC;
}

- (void)handleTap1:(UITapGestureRecognizer *)tap {
    
}

- (IBAction)actionContr:(id)sender {
    if ([BTManager sharedBTManager].isConnected) {
        DCControlViewController *vc = [[DCControlViewController alloc] initWithNibName:@"DCControlViewController" bundle:nil];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (void)handleTap2:(UITapGestureRecognizer *)tap {
    NSURL *url = [NSURL URLWithString:@"https:www.powertechsystems.eu"];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
    }
}

- (void)handleTap:(UITapGestureRecognizer *)tap {
    if ([BTManager sharedBTManager].isConnected) {
        DeviceSettingViewController *vc = [[DeviceSettingViewController alloc] initWithNibName:@"DeviceSettingViewController" bundle:nil];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

@end
